<template>
	<z-paging ref="paging" v-model="list" @query="getList" empty-view-text="暂无数据"
		:empty-view-img-style="{width:'150rpx',height:'150rpx'}" :empty-view-title-style="{marginTop: '30rpx'}">
		<template #refresher="{refresherStatus}">
			<custom-refresher :status="refresherStatus" />
		</template>
		<view class="pad-left-right-24">
			<view v-for="item in list" :key="item.id" @click="hanldeNoticeInfo(item.id)" class="mar-top-30 font-28">
				<view>{{item.title}}</view>
				<view class="mar-top-10 border-bottom color-646464">
					{{timeFormat(item.created_at, 'yyyy-mm-dd hh:MM:ss')}}
				</view>
			</view>
		</view>
	</z-paging>
</template>

<script setup>
	import { ref } from 'vue';
	import { noticeList } from '@/api/index.js'
	import { timeFormat } from '@/node_modules/uview-plus';

	const list = ref([]);
	const paging = ref(null);

	// 获取列表数据
	const getList = (page, pageSize) => {
		noticeList({
			page,
			ps: pageSize
		}).then(res => {
			if (res?.code == 200) {
				paging.value.complete(res.data.data);
			} else {
				paging.value.complete(false);
			}
		})
	}
	
	// 跳转公告详情
	const hanldeNoticeInfo = (id) => {
		uni.navigateTo({
			url: '/pages/noticeDetails/noticeDetails?id=' + id
		})
	}
</script>

<style scoped>
	.border-bottom {
		border-bottom: 1rpx solid #e2d3d3;
		padding-bottom: 30rpx;
	}
</style>